package com.zst.kafka.nospring.client;

import org.apache.kafka.clients.admin.*;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Properties;
import java.util.concurrent.ExecutionException;

public class KafkaAdmin {
    public static void main(String[] args) {
        Properties props = new Properties();
        props.setProperty("bootstrap.servers", "192.168.123.46:19001");

        try (Admin adminClient = Admin.create(props)) {
            NewTopic topic = new NewTopic("test-topic", 3, (short) 3);
            CreateTopicsResult result = adminClient.createTopics(Arrays.asList(topic));
            result.values().get("test-topic").get();
//            DescribeTopicsResult result = adminClient.describeTopics(Arrays.asList("test-topic"));
//            System.err.println(result.allTopicNames().get().get("test-topic").toString());
        } catch (ExecutionException e) {
            throw new RuntimeException(e);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

    }
}
